﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;

namespace OnlineEducation.Data.Entities
{
    public class Code : EntityBase
    {
        public Code()
        {
            this.Status = 1;
        }
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int ID { get; set; }

        [StringLength(100)]
        [Required(ErrorMessage ="值不能为空")]      
        public string Category { get; set; }

        [StringLength(100)]
        [Required(ErrorMessage = "值不能为空")]
        public string Name { get; set; }

        [StringLength(100)]
        [Required(ErrorMessage = "值不能为空")]
        public string Value { get; set; }

        [StringLength(100)]
        public string Value2 { get; set; }

        [StringLength(100)]
        public string Value3 { get; set; }

        [StringLength(200)]
        public string Description { get; set; }

    
        [Required]
        [Display(Name ="状态")]
        public int Status { get; set; }

        [StringLength(200)]
        [Display(Name = "备注")]
        public string Remark { get; set; }

        [ForeignKey("ParentCode")]
        public int? ParentID { get; set; }

        [ForeignKey("ParentID")]
        public ICollection<Code> ChildCodes { get; set; }

        public Code ParentCode { get; set; }

    }
}
